package javas.net;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class TestUdpReceive {
	
	public static void main(String[] args) throws IOException {
	   DatagramSocket ds = new DatagramSocket(10000);
	   ds.setSendBufferSize(1024);
	   
	   byte[] buf = new byte[1024];
	   DatagramPacket dp = new DatagramPacket(buf, buf.length);
	   ds.receive(dp);
	   String str = new String(dp.getData(), 0, dp.getLength());
	   System.out.println(str);
	   System.out.println("IP:" + dp.getAddress().getHostAddress() + ",PORT:" + dp.getPort());
	   ds.close();
	   
	   
	}

}
